<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/js/axios.min.js"></script>
    <script src="/js/util.js"></script>
    <script>
        function add(){
            var formObj = new FormData();
            //添加文本表单数据
            formObj.append("userName",$("userName").value);
            //添加文件表单数据
            formObj.append("face",$("faceTxt").files[0]);
            let config = {
                headers: {'Content-Type': 'multipart/form-data' }
            }
            axios.post("/test/upload",formObj,config).then(resp =>{
                var info = resp.data;
                alert(info);
            })
        }
    </script>
</head>
<body>
    用户名：<input type="text" id="userName"><br>
    <img src="" id="faceImg" width="200" height="240"><br>
    头像：<input type="file" id="faceTxt" onchange="fileChange('faceTxt','faceImg')"><br>
    <input type="button" value="提交" onclick="add()">
</body>
</html>